package robot.arm;

import com.sun.j3d.utils.geometry.*;

import com.sun.j3d.utils.universe.*;

import javax.media.j3d.*;

import javax.vecmath.*;

public abstract class Link {
	
	protected float linkLength; // most of the Java3D classes use floats it seems, not doubles
	protected int color; // may turn this into an array
	
	// I'm still trying to figure out how to retain the state of a position, but we'll use a Vector3d member for now
	protected Vector3f position;
	
	//protected String name;  // just in case we need some way to identify which link it is
	protected Cylinder linkShape;
	protected Joint attachedJoint;  // the Joint will actually move the Link;
	protected String linkName;

	
	
	public Link(float height, Color3f initialColors) {
		// make the cylinder
		Appearance initStuff = new Appearance();
		
	      ColoringAttributes prettyColors = new ColoringAttributes(initialColors, ColoringAttributes.NICEST);
	      
	      Material shiny = new Material();
	      
	      shiny.setAmbientColor(0.1f, 0.1f, 0f);
	      
	      shiny.setSpecularColor(0.1f, 0.1f, 0.1f);
	      
	      shiny.setDiffuseColor(1.0f, 1.0f, 0.0f);
	      
	      shiny.setShininess(0.05f);
	      
	      
	      
	      initStuff.setColoringAttributes(prettyColors);
	      initStuff.setMaterial(shiny);
	      
	      linkShape = new Cylinder(0.1f, height, Cylinder.ENABLE_APPEARANCE_MODIFY | Cylinder.GENERATE_NORMALS, 25, 25, initStuff);
		
	}
	
	public Link(float height) {
			// make the cylinder
		
		Appearance initStuff = new Appearance();
		
		Color3f initialColors = new Color3f(255.0f, 0.0f, 0.0f);
		
	      ColoringAttributes prettyColors = new ColoringAttributes(initialColors, ColoringAttributes.NICEST);
	      
	      Material shiny = new Material();
	      
	      shiny.setAmbientColor(0.1f, 0.1f, 0f);
	      
	      shiny.setSpecularColor(0.1f, 0.1f, 0.1f);
	      
	      shiny.setDiffuseColor(1.0f, 1.0f, 0.0f);
	      
	      shiny.setShininess(0.05f);
	      
	      
	      
	      initStuff.setColoringAttributes(prettyColors);
	      initStuff.setMaterial(shiny);
	      
	      linkShape = new Cylinder(0.1f, height, Cylinder.ENABLE_APPEARANCE_MODIFY | Cylinder.GENERATE_NORMALS, 25, 25, initStuff);
	}
	
	public Link() {
		// not sure what goes in yet
		
		// default shape 
		
		Appearance initStuff = new Appearance();
		
		Color3f initialColors = new Color3f(255.0f, 0.0f, 0.0f);
		
	      ColoringAttributes prettyColors = new ColoringAttributes(initialColors, ColoringAttributes.NICEST);
	      
	      Material shiny = new Material();
	      
	      shiny.setAmbientColor(0.1f, 0.1f, 0f);
	      
	      shiny.setSpecularColor(0.1f, 0.1f, 0.1f);
	      
	      shiny.setDiffuseColor(1.0f, 1.0f, 0.0f);
	      
	      shiny.setShininess(0.05f);
	      
	      
	      
	      initStuff.setColoringAttributes(prettyColors);
	      initStuff.setMaterial(shiny);
	      
	      linkShape = new Cylinder(0.1f, 0.75f, Cylinder.ENABLE_APPEARANCE_MODIFY | Cylinder.GENERATE_NORMALS, 25, 25, initStuff);
	}
	
	public abstract void moveLink(Vector3f direction);
	
	public abstract void moveLink();
	
	public abstract Vector3f getPosition();
	
	public abstract Cylinder getShape();
	
	public void changeLength(float newLength) {
		linkLength = newLength;
		// make the change to the new length in the object
	}
	
	public String getName() {
		return linkName;
	}

}
